package scau.jump.securitytrace.client.rolelistener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class RoleListenerController implements ActionListener {

	private RoleActionListener roleActionListener;
	
	public RoleListenerController(RoleActionListener roleActionListener) {
		this.roleActionListener = roleActionListener;
	}
	
	@Override
	public void actionPerformed(ActionEvent event) {
		String methodName = event.getActionCommand();
		try {
			Method excuteMethod = roleActionListener.getClass().getDeclaredMethod(methodName, new Class<?>[]{});
			excuteMethod.invoke(roleActionListener, new Object[]{});
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
}
